package com.person.ntv.service.sys.impl;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.person.common.PageParams;
import com.person.exception.ServiceException;
import com.person.ntv.dao.sys.SysOrgMapper;
import com.person.ntv.entity.sys.SysOrg;
import com.person.ntv.service.base.impl.BaseServiceImpl;
import com.person.ntv.service.sys.CommonService;
import com.person.ntv.service.sys.SysOrgService;
@Service("sysOrgService")
public class SysOrgServiceImpl extends BaseServiceImpl<SysOrg> implements SysOrgService{
	@Autowired
   private SysOrgMapper sysOrgMapper;
	@Autowired
   private CommonService commonService;
	@Autowired
   public void setBaseMapper(){
	   super.setBaseMapper(this.sysOrgMapper);
   }

@Override
public int deleteByPrimaryKeys(BigDecimal[] ids) {
	try{
		int result=0;
	    for(BigDecimal id:ids){
	    	result+=deleteByPrimaryKey(id);
	    }
	    return result;
		}catch (Exception e) {
	          e.printStackTrace();
	          throw new ServiceException("系统错误。");
	  }
}


@Override
public Page<Map<String,Object>> getOrgPage(PageParams params)
		throws ServiceException {
	try{
		PageHelper.startPage(params.getPage(),params.getRows(),params.getOrderStr(null));
		return sysOrgMapper.selectPage(params.getParams());
		}catch (Exception e) {
	          e.printStackTrace();
	          throw new ServiceException("系统错误。");
	  } 
}

@Override
public List<Map<String, Object>> getOrgDeptUser(String roleId)throws ServiceException {
	try{
		return sysOrgMapper.getOrgDeptUser(roleId);
		}catch (Exception e) {
	          e.printStackTrace();
	          throw new ServiceException("系统错误。");
	  } 
}
   
}
